#include"process.h"
#include<string.h>

#define NUM 101
#define STYLE '='

void process_v1()
{
    char arr[NUM];
    const char images[] = "-\\|/";
    int len = strlen(images);
    memset(arr,0,NUM);
    for(int i = 0;i<NUM;i++)
    {
        printf("[%-100s][%c][%3d%%]\r",arr,images[i%len],i);
        fflush(stdout);
        arr[i] = STYLE;
        usleep(10000);
    }
    printf("\n");
}


void process_v2(double cur,double total)
{
    char arr[NUM];
    const char images[] = "-\\|/";
    static int cnt = 0;
    int len = strlen(images);
    memset(arr,0,NUM);
    double rate = cur/total*100;
    int num = (int)rate;
    for(int i = 0;i<num;i++)
    {
        arr[i] = STYLE;
    }
    printf("[%-100s][%c][%.1lf%%]\r",arr,images[cnt++%len],rate);
}
